package com.soundShape.mediators.menu
{
	
	import com.soundShape.events.SoundShapeEvent;
	import com.soundShape.mediators.AbstractViewMediator;
	import com.soundShape.model.ApplicationModel;
	import com.soundShape.views.menu.Menu;
	import com.soundShape.views.newEmployee.NewEmployee;
	import com.soundShape.vo.EmployeeVO;
	
	import flash.events.Event;
	import flash.events.KeyboardEvent;
	import flash.events.MouseEvent;
	
	import mx.collections.ArrayCollection;
	import mx.controls.Alert;
	import spark.components.Button;
	import mx.core.UIComponent;
	import mx.effects.Move;
	import mx.effects.Rotate;
	import mx.events.FlexEvent;
	import mx.events.ValidationResultEvent;
	import mx.managers.PopUpManager;
	import mx.validators.ValidationResult;
	
	import spark.components.BorderContainer;
	import spark.components.TextInput;
	
	
	public class MenuMediator extends AbstractViewMediator
	{
		
				
				
				public function MenuMediator()
				{
					super(Menu);
				}
				
				/**
				 * Since the AbstractViewMediator sets the view via Autowiring in Swiz,
				 * we need to create a local getter to access the underlying, expected view
				 * class type.
				 */
				public function get view():Menu
				{
					return this._view as Menu;
				}
				
				/**
				 * The <code>init()</code> method is fired off automatically by the 
				 * AbstractViewMediator when the creation complete event fires for the
				 * corresponding ViewMediator's view. This allows us to listen for events
				 * and set data bindings on the view with the confidence that our view
				 * and all of it's child views have been created and live on the stage.
				 */
				override protected function init():void
				{
					super.init();
					
					this.setViews();
					
				}
				
				override protected function setViewDataBindings():void
				{
					super.setViewDataBindings();
					
				}	
				
				override protected function setViewListeners():void
				{
					super.setViewListeners(); 
					
					this.view.btnAdmin.addEventListener(MouseEvent.CLICK, handleMenuEvent);
					this.view.btnFollowUp.addEventListener(MouseEvent.CLICK, handleMenuEvent);
					this.view.btnFreeConsultation.addEventListener(MouseEvent.CLICK, handleMenuEvent);
					this.view.btnNewCustomer.addEventListener(MouseEvent.CLICK, handleMenuEvent);
					this.view.btnManagePhoto.addEventListener(MouseEvent.CLICK, handleMenuEvent);
					this.view.btnTransaction.addEventListener(MouseEvent.CLICK, handleMenuEvent);
					this.view.btnTreatment.addEventListener(MouseEvent.CLICK, handleMenuEvent);
					this.view.btnReporting.addEventListener(MouseEvent.CLICK, handleMenuEvent);
					this.view.btnComparison.addEventListener(MouseEvent.CLICK, handleMenuEvent);
					
					//this.view.btnLogin.addEventListener(MouseEvent.CLICK, handleBtnLogin);
					
				}
				
				private function setViews():void
				{
					
				}
				
				
				
				/**
				 * *******************************************************************************
				 * Handlers
				 * *******************************************************************************
				 */
				
				private function handleMenuEvent(mouseEvent:MouseEvent):void
				{
					switch(Button(mouseEvent.currentTarget).id)
					{
						case "btnAdmin":
							this.dispatcher.dispatchEvent(new SoundShapeEvent(SoundShapeEvent.SWITCH_TO_ADMIN_VIEW));
							break;
						
						case "btnFollowUp":
							this.dispatcher.dispatchEvent(new SoundShapeEvent(SoundShapeEvent.SWITCH_TO_FOLLOW_UP_VIEW));
							break;
						
						case "btnFreeConsultation":
							this.dispatcher.dispatchEvent(new SoundShapeEvent(SoundShapeEvent.SWITCH_TO_FREE_CONSULTATION_VIEW));
							break;
						
						case "btnNewCustomer":
							this.dispatcher.dispatchEvent(new SoundShapeEvent(SoundShapeEvent.SWITCH_TO_NEW_CUSTOMER_VIEW));
							break;
						
						case "btnManagePhoto":
							this.dispatcher.dispatchEvent(new SoundShapeEvent(SoundShapeEvent.SWITCH_TO_PHOTOS_VIEW));
							break;
						
						case "btnTransaction":
							this.dispatcher.dispatchEvent(new SoundShapeEvent(SoundShapeEvent.SWITCH_TO_TRANSACTIONS_VIEW));
							break;
						
						case "btnTreatment":
							this.dispatcher.dispatchEvent(new SoundShapeEvent(SoundShapeEvent.SWITCH_TO_TREATMENT_VIEW));
							break;
						
						case "btnReporting":
							this.dispatcher.dispatchEvent(new SoundShapeEvent(SoundShapeEvent.SWITCH_TO_REPORTING_VIEW));
							break;
					
						case "btnComparison":
							this.dispatcher.dispatchEvent(new SoundShapeEvent(SoundShapeEvent.SWITCH_TO_COMPARISON_VIEW));
							break;
						
						
					}
				}
				
				private function handleBtnLogin(mouseEvent:MouseEvent):void
				{
					this.dispatcher.dispatchEvent(new SoundShapeEvent(SoundShapeEvent.SWITCH_TO_LOGIN_VIEW));
				}
				
				/**
				 * *******************************************************************************
				 * Swiz EventHandlers
				 * *******************************************************************************
				 */
				
		}
		
	}
